#ifndef TDOWNLOADDIALOG_H
#define TDOWNLOADDIALOG_H

#include "TContext.h"
#include "TSkinDialog.h"
#include <QVBoxLayout>

class QProgressBar;

class PreDownUi : public QWidget
{
    Q_OBJECT
public:
    PreDownUi(QWidget* parent = 0);

    QVBoxLayout *verticalLayout;
    QSpacerItem *verticalSpacer;
    QPushButton *pbtOpen;
    QSpacerItem *verticalSpacer_2;
    QPushButton *pbtSaveAs;
    QSpacerItem *verticalSpacer_3;
};

class DownUi : public QWidget
{
    Q_OBJECT
public:
    DownUi(QWidget* parent = 0);

    QVBoxLayout *verticalLayout;
    QSpacerItem *verticalSpacer;
    QLabel *label;
    QProgressBar *progressBar;
    QHBoxLayout *horizontalLayout;
    QSpacerItem *horizontalSpacer;
    QPushButton *pbtCancel;
};

class TDownloadDialog : public TSkinDialog
{
    Q_OBJECT

public:
    enum Mode
    {
        DirectOpen = 0,
        SaveAs
    };

public:
    TDownloadDialog(TDocumentPointer pDoc, QWidget* parent = 0);

private slots:
    void doDownload();
    void downloadFinished(bool error, QString localFilename);
    void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);

private:
    void setPreDownUi();
    void setDownUi();

private:
//    Ui::TDownloadingDialog* uiDown;
//    Ui::TPreDownloadDialog* uiPreDown;
    PreDownUi* _wPreDown;
    DownUi* _wDown;

    TDownloadRequesterPointer _requester;
    TDocumentPointer _pDoc;
    Mode _mode;
};

#endif // TDOWNLOADDIALOG_H
